package com.webull.information.center.carwler.job;

import java.net.InetAddress;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.webull.information.center.carwler.common.model.CollectRecord;
import com.webull.information.center.carwler.dao.CollectRecordDao;
import com.webull.information.center.carwler.task.News_Bloomberg_Stocks_Task;

/**
 * top news
 */
@Component
public class News_BloombergTopNews_Job implements SimpleJob {
    protected final Logger logger = LogManager.getLogger(getClass());
	private @Autowired CollectRecordDao collectRecordDao;
	private @Autowired News_Bloomberg_Stocks_Task News_Bloomberg_Stocks_Task;
	private final String collectJob = "news_BloombergTopNews_Job";


    @Override
	public void execute(ShardingContext context) {
		logger.info("news_ReutersGuideTopNews_Job start");
		News_Bloomberg_Stocks_Task.handlerTopNews2();
		Integer collId = collectRecordDao.add(backRecord());
		logger.info("news_ReutersGuideTopNews_Job end id:{}", collId);
	}


    private CollectRecord backRecord() {
        CollectRecord record = new CollectRecord();
        record.setCollectJob(collectJob);
        record.setExchangeCode("exchangeCode");
        record.setExchangeId(0);
        record.setRecordType(CollectRecord.RecordTypeConstants.NEWS);
        try {
            record.setCustomer(InetAddress.getLocalHost().getHostAddress());
        } catch (Exception e) {
        }
        return record;
    }
}
